package com.example.zq.providerextends;

import com.example.zq.HelloService;
import com.example.zq.User;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : Zhang Qi
 * @date : 2019/11/25
 */
@RestController
public class HelloController implements HelloService {
  private Map<Integer,User> userMap=new HashMap<>();

  @Override public String hello(String name) {
    return "Hello,"+name+"!";
  }

  @Override public void deleteUserById(Integer id) {
    userMap.remove(id);
  }

  @Override public User getUserById(Integer id) {
    return userMap.get(id);
  }

  @Override public User addUser(User user) {
    int id = user.getId();
    userMap.put(id,user);
    return userMap.get(id);
  }

  @Override public void updateUserById(String name, Integer id) {
    User user = userMap.get(id);
    user.setUsername(name);
  }
}
